<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: 32266
  Date: 2023/5/19
  Time: 16:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--<%@taglib prefix="" uri="http://java.sun.com/jsp/jstl/core" %>--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>jstl demo</title>
</head>
<body>
    This is my JSP page.<br/>
    <h2>The "if" Tag</h2>
    <ul>
        <c:forEach var="i" begin="1" end="10">
            <li>${i}</li>
            <c:if test="${i>7}">
                (greater than 7)
            </c:if>
        </c:forEach>
    </ul>

    <hr/>
    <h2>The "choose" Tag</h2>
    <ul>
        <c:forEach var="i" begin="1" end="10">
            <li>${i}</li>
            <c:choose>
                <c:when test="${i<4}">
                    (small)
                </c:when>
                <c:when test="${i<8}">
                    (medium)
                </c:when>
                <c:otherwise>
                    (large)
                </c:otherwise>
            </c:choose>
        </c:forEach>
    </ul>
<%--    <%--%>
<%--//        String username = "Yangjile";--%>
<%--//        request.setAttribute("username",username);--%>
<%--    %>--%>
<%--    <c:set var="username" value="Wangle" scope="session"/>--%>
<%--    <c:set var="password" value="123456" scope="request"/>--%>
<%--    <br/>Password: (Before remove) :${password}--%>
<%--    <c:remove var="password" scope="request"/>--%>
<%--    <br/>After remove: ${password}--%>
<%--    <h1>Welcome ,<c:out value="${username}" default="Guest"/></h1>--%>
<%--    <h1>Use c:forEach to print 1 to 10</h1>--%>
<%--<c:forEach var="i" begin="1" end="10" step="1">--%>
<%--    <ul>--%>
<%--        <li>${i}</li>--%>
<%--    </ul>--%>
<%--</c:forEach>--%>
<%--<h1>print 1,3,5,7,9</h1>--%>
<%--<c:forEach var="j" begin="1" end="10" step="2">--%>
<%--    <ul>--%>
<%--        <li>${j}</li>--%>
<%--    </ul>--%>
<%--</c:forEach>--%>

<%--<h1> User c:forEach to get items from a Array</h1>--%>
<%--<%--%>
<%--    String[] firstname = {"Yang", "Wang", "Zhang"};--%>
<%--    request.setAttribute("firstname", firstname);--%>
<%--    ArrayList<String> lastname = new ArrayList<>();--%>
<%--    lastname.add("jile");--%>
<%--    lastname.add("le");--%>
<%--    lastname.add("shan");--%>
<%--    request.setAttribute("lastname", lastname);--%>
<%--%>--%>
<%--    <c:forEach var="f" items="${firstname}">--%>
<%--        <ul>--%>
<%--            <li>${f}</li>--%>
<%--        </ul>--%>
<%--    </c:forEach>--%>

<%--    <h1> Use c:forEach to print items from ArrayList </h1>--%>
<%--    <c:forEach var="l" items="${lastname}">--%>
<%--        <ul>--%>
<%--            <li>${l}</li>--%>
<%--        </ul>--%>
<%--    </c:forEach>--%>

<%--<h1> Use c:forTokens </h1>--%>
<%--<c:forTokens var="t" items="one,two,three,four.five.six" delims=",.">--%>
<%--    <ul>--%>
<%--        <li>${t}</li>--%>
<%--    </ul>--%>
<%--</c:forTokens>--%>
<%--<c:catch var="msg">--%>
<%--    <%--%>
<%--        int i = 1/0;--%>
<%--    %>--%>
<%--</c:catch>--%>
<%--Message: ${msg}--%>
</body>
</html>